home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / quicktime / quicktimeintro / graphic import.export / start code / drawimage.c < prev    next >
Encoding:
Text File  |  2000-10-06  |  1.4 KB  |  51 lines

  1. // Graphics Importer and Exporter Samples
  2. // This sample simply draws an image from a file using Graphics Importers
  3. // Originally written by Sam Bushell for QuickTime "Live" '99
  4. // WWDC 2000 Introduction to QuickTime
  5.  
  6. #include "MacShell.h"
  7.  
  8. void DrawImage( void )
  9. {
  10.     OSErr err = noErr;
  11.     Handle hOpenTypeList = NewHandle(0);
  12.     long  numTypes = 0;
  13.     FSSpec theFSSpec;
  14.     Rect bounds;
  15.     GraphicsImportComponent importer = 0;
  16.     WindowPtr window = NULL;
  17.     
  18.     BuildGraphicsImporterValidFileTypes( hOpenTypeList, &numTypes );
  19.     HLock( hOpenTypeList );
  20.  
  21.     err = GetOneFileWithPreview(numTypes, (OSTypePtr)*hOpenTypeList, &theFSSpec, NULL);
  22.     DisposeHandle( hOpenTypeList );
  23.     if ( err ) return;
  24.     
  25.     // locate and open a graphics importer component which can be used to draw the
  26.     // selected file. If a suitable importer is not found the ComponentInstance
  27.     // is set to NULL.
  28. // Step 1. Insert GetGraphicsImporterForFile.clp here...
  29.  
  30.         
  31.     // get the native size of the image associated with the importer                              
  32. // Step 2. Insert GetNaturalBounds.clp here...
  33.  
  34.     
  35.     OffsetRect( &bounds, 10, 45 );
  36.     window = NewCWindow( NULL, &bounds, "\pDraw Image", true, documentProc, (WindowPtr)-1, true, 0);
  37.     
  38.     // set the graphics port for drawing
  39. // Step 3. Insert GraphicsImportSetGWorld.clp here...
  40.  
  41.     
  42.     // draw the image
  43. // Step 4. Insert GraphicsImportDraw.clp here...
  44.  
  45.     
  46.     // close the importer instance
  47. // Step 5. Insert CloseComponent.clp here...
  48.  
  49.  
  50. }
  51.